﻿using IdentityServer3.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EmbeddedMVC
{
    public static class CustomClients
    {

        private static string redirecturl = System.Configuration.ConfigurationManager.AppSettings["RedirectUri"].ToString();
        private static string client1url = System.Configuration.ConfigurationManager.AppSettings["Client1Uri"].ToString();
        private static string client2url = System.Configuration.ConfigurationManager.AppSettings["Client2Uri"].ToString();
        private static string client3url = "http://localhost:60631/";

        public static IEnumerable<Client> Get()
        {
            return new[]
            {
              //client1
             new Client
            {
                Enabled = true,
                ClientName = "client1",
                ClientId = "client1",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                LogoutUri = client1url+"Account/SignoutCleanup",
                 RedirectUris = new List<string>
                    {
                        client1url
                    },
                 PostLogoutRedirectUris = new List<string>
                    {
                        client1url
                    }
            },

                  new Client
            {
                Enabled = true,
                ClientName = "client2",
                ClientId = "client2",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                LogoutUri = client2url+"Account/SignoutCleanup",
                 RedirectUris = new List<string>
                    {
                        client2url
                    },
                 PostLogoutRedirectUris = new List<string>
                    {
                        client2url
                    }
            },

             new Client
            {
                Enabled = true,
                ClientName = "client3",
                ClientId = "client3",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                LogoutUri = client3url+"Account/SignoutCleanup",
                 RedirectUris = new List<string>
                    {
                        client3url
                    },
                 PostLogoutRedirectUris = new List<string>
                    {
                        client3url
                    }
            },

            //本地客户端
            new Client
            {
                Enabled = true,
                ClientName = "MVC Client",
                ClientId = "mvc",
                Flow = Flows.Implicit,

                RedirectUris = new List<string>
                {
                    redirecturl
                },

                PostLogoutRedirectUris = new List<string>
               {
                  redirecturl
                },

               AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "sampleApi"
               }
            }
        };
        }
    }
}